-- 包含
require "Button"
-- 菜单类
Menu = {
    backgroundColor = {0, 0, 0},
    width = 0,
    height = 0,
    numButton = 0,
    x = 0,
    y = 0,
    origin_x = 0,
    origin_y = 0,
    listOfButton = {}
}
-- 创建菜单
function Menu:new(o, origin_width, origin_height)
    o = o or {}
    setmetatable(o, self)
    self.__index = self
    o.height = origin_height or 100
    o.width = origin_width or 100
    o.x, o.y = love.graphics.getDimensions()
    o.x, o.y = o.x / 2, o.y / 2
    o.origin_x, o.origin_y = origin_width / 2, origin_height / 2
    o.backgroundColor = {0, 0, 0}
    o.listOfButton = {}
    return o
end
-- 将按钮加入菜单
function Menu:addButton(Button)
    table.insert(self.listOfButton, Button)
end
-- 绘制菜单和菜单内的按钮
function Menu:draw()
    love.graphics.setColor(love.math.colorFromBytes(self.backgroundColor))
    love.graphics.setLineWidth(2)
    love.graphics.rectangle("line", self.x - self.origin_x, self.y - self.origin_y, self.width, self.height, self.rx,
        self.ry)
    for i, v in ipairs(self.listOfButton) do
        v:draw()
    end
end
-- 判断是否按下菜单内的按钮
function Menu:downButtons(x, y, button)
    for i, v in ipairs(self.listOfButton) do
        v:Down(x, y, button)
    end
end
